package com.youlv.yl.controller;

import com.youlv.yl.config.SystemConfig;
import com.youlv.yl.service.intf.UserLevelService;
import com.youlv.yl.service.intf.UserSignService;
import com.youlv.yl.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fenghe
 * @since 2022-01-12
 */
@RestController
@RequestMapping("/yl/userSign/")
@Api(value = "实现用户签到的相关操作", tags = "实现用户签到的相关操作")
@CrossOrigin
public class UserSignController {

    @Autowired
    private UserSignService service;
    @Autowired
    private UserLevelService levelService;

    /** 判断当前用户可以签到*/
    @GetMapping("checkSign.do")
    public R checkSign(HttpServletRequest request) {
        String token = request.getHeader(SystemConfig.REQ_HEADER_TOKEN);
        return service.checkSign(token);
    }

    /** 实现当前用户的签到*/
    @GetMapping("addSign.do")
    public R addSign(HttpServletRequest request) {
        String token = request.getHeader(SystemConfig.REQ_HEADER_TOKEN);
        return service.addSign(token);
    }

    /** 查询当前用户分数等级*/
    @GetMapping("queryScore.do")
    public R queryScore(HttpServletRequest request) {
        String token = request.getHeader(SystemConfig.REQ_HEADER_TOKEN);
        return levelService.queryScore(token);
    }
}
